<?php
namespace app\home\controller;
use think\Db;
use think\captcha\Captcha;
use think\Loader;
class Shoppingcart extends \think\Controller{
    public function shoppingcart(){
        $id=$_GET['id'];

        $data=[
            'shop_id'=>$id,
        ];
        $reslist=db('shoppingcart')->insertGetId($data);

        $ret=db('shoppingcart')->alias('a')->join('admin_addshop b',' a.shop_id=b.id ')
        ->field('b.*')->select();

        $data=array();
        foreach($ret as $val){
            $img=json_decode($val['img'],true);
            if($img!=NULL){
                $val['img']=$img;
            }
            $data[]=$val;
        }
        $this->assign('ret',$data);

        return $this->fetch('shoppingcart');//继承基类的控制器 
    }
    public function delete(){
        $delId=input('param.delId','','htmlspecialchars');
        $res=db('shoppingcart')->where('shop_id',$delId)->delete();
        if($res>0){
            $this->success('删除成功!');
        }else{
            $this->error('删除失败');
        }
    }
    
}